import { getAdminInfoByTokenApi } from "@/api/doctor";
import { defineStore } from "pinia";

export const useGlobalStore = defineStore('global', {
  state: () => {
    return {
      // 用户信息 数据
      adminInfo: {
        roleId: { permissions: [] }
      },
    }
  },
  getters: {
    permissionData(state) {
      return state.adminInfo.roleId.permissions;
    }
  },
  actions: {
    // 获取 用户信息数据的 方法
    async getAdminInfoByTokenAction() {
      const res = await getAdminInfoByTokenApi();
      if (res.code == 200) {
        this.adminInfo = res.data;
      }
    },
  }
})